﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication5.settings
{
    /*
     * Dynamische Routerkonfiguration mit RIPv2
     */
    public class Ripv2_Routerconfig
    {
        private List<String> ipList;
        private bool routingprotocol_RIPv2_enable;
        private bool autocomplete_RIPv2;

        /*
         * Getter und Setter
         */
        public List<String> Directconnect_RIPv2
        {
            get { return ipList; }
            set { ipList = value; }
        }
         
        public bool Routingprotocol_RIPv2_enable
        {
            get { return routingprotocol_RIPv2_enable; }
            set { routingprotocol_RIPv2_enable = value; }
        }

        public bool Autocomplete_RIPv2
        {
            get { return autocomplete_RIPv2; }
            set { autocomplete_RIPv2 = value; }
        }

        /**
         * Konstruktor für die RIPv2 Konfiguation
	     * @param ipList Liste der direktverbundenen Netzwerke
         * @param rip_protocol_enabled Status der Protokollaktivierung
         * @param rip_autocomplete Status der automatischen Zusammenfassung
	     */
        public Ripv2_Routerconfig(List<String> ipList, Boolean rip_protocol_enabled, Boolean rip_autocomplete)
        {
            Directconnect_RIPv2 = ipList;
            Routingprotocol_RIPv2_enable = rip_protocol_enabled;
            Autocomplete_RIPv2 = rip_autocomplete;
        }

        /**
         * Baut den Ausgabe-String für die RIPv2-Konfiguration zusammen
         * und gibt ihn zurück
         */
        public String toString()
        {
            String ret = "";
            if (routingprotocol_RIPv2_enable == true)
            {
                ret += "router rip" + Environment.NewLine;
                ret += " version 2 " + Environment.NewLine;

                for (int i = 0; i < ipList.Count; i++)
                {
                    ret += " network " + ipList[i] + Environment.NewLine;
                }

                if (autocomplete_RIPv2 == true)
                {
                    ret += " auto-summary" + Environment.NewLine;
                }
                else
                {
                    ret += " no auto-summary" + Environment.NewLine;
                }
                ret += "!" + Environment.NewLine;
            }

            return ret;
        }

    }
}
